package com.Ryan.B_Controller;

import java.util.List;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.Ryan.A_Bean.User;
import com.Ryan.C_Service.UserServiceInte;

@RestController
public class UserController {
	@Autowired
	private UserServiceInte userServiceInte;

	@RequestMapping("index")
	public String index() {
		return "index";
	}

	@RequestMapping("find_userList")
	public List<User> find_userList() {
		return userServiceInte.find_userList();
	}

	@RequestMapping("save_user")
	public Integer save_user() {
		return userServiceInte.save_user(new User());
	}
	
	@RequestMapping("find_userAll")
	public List<User> find_userAll() {
		return userServiceInte.find_userAll();
	}
	
	@RequestMapping("/upload")
	public String upload(@RequestParam("file")MultipartFile file) {
		String originalFilename = file.getOriginalFilename();
		return originalFilename;
	}
	
	@RequestMapping("/uploads")
	public String uploads(@RequestParam("file")MultipartFile[] file) {
		for (MultipartFile multipartFile : file) {
			System.out.println(multipartFile.getOriginalFilename());
		}
		return file.length+"";
	}


}
